const { Controller } = require('egg');

class BaseController extends Controller {

  success(data) {
    const { ctx } = this;
    ctx.body = {
      data,
      errcode: 0,
    };
    ctx.status = 201;
  }

  error(errcode, errmsg) {
    const { ctx } = this;
    ctx.body = {
      errmsg,
      errcode,
    };
    ctx.status = 201;
  }

}

module.exports = BaseController;
